package com.flycms.module.app.enums;

import lombok.Getter;

import java.util.Objects;

public enum DeliveryTypeEnum {
    FREE(1,"免费"),
    FREE_TEST(2,"免费试用"),
    PAY(3,"收费");

    DeliveryTypeEnum(Integer code, String desc){
        this.code = code;
        this.desc = desc;
    }

    @Getter
    Integer code;

    @Getter
    String desc;

    /**
     * 根据code值获取枚举描述
     * @param code 值
     * @return 对应描述
     */
    public static String getDescByCode(Integer code) {
        if(Objects.isNull(code)){
            return "";
        }
        DeliveryTypeEnum[] values = values();
        for (DeliveryTypeEnum anEnum : values) {
            if(code == anEnum.getCode()){
                return anEnum.getDesc();
            }
        }
        return "";
    }
}
